<template>
    <div class="pricing">
        <SynchronizeBrand />

        <div class="pricing-list" v-for="(product,index) in clothes" :key="product.design_id">
            <div class="pricing-title">
                <strong>
                    <img v-if="index == 0" src="@/assets/images/synchronize/synchronize-title.png" alt="">
                    <img v-if="index == 1" src="@/assets/images/synchronize/synchronize-title2.png" alt="">
                    Set product price of {{product.sub_title}}
                </strong>

                <span v-show="shop.ss_currency != 'USD'">
                    Your store currency is non-USD. To ensure an ideal profit margin, please enter the retail prices manually.
                </span>

                <a @click="openShipping()">
                    <img src="https://img.podpartner.com/static/images-20230202/synchronize-price-shipping.png" />
                    <em>Shipping rates</em>
                </a>
            </div>

            <SynchronizePriceVariants :product="product" />

        </div>

        <div class="pricing-switch" v-if="status.action == 'create'">
            <p :class="{ active: !display }" @click="display = false">
                <span>Hide in store</span>
            </p>
            <p :class="{ active: display }" @click="display = true">
                <span>Visible in store</span>
            </p>
        </div>
        <div v-else style="height:36px;"></div>

    </div>
</template>
<script>
import { mapGetters, mapState } from "vuex";
export default {
    name: "SynchronizePricing",
    data () {
        return {
            shippingDialog: false,
        };
    },
    computed: {
        ...mapState("synchronize", {
            clothes: "clothes",
            setting: "setting",
            status: "status",
            shop: "shop",
        }),

        // 是否显示在店铺中
        display: {
            get () {
                return this.setting.display;
            },
            set (val) {
                if (this.setting.display != val) {
                    this.setting.display = val;
                }
            },
        },

    },
    methods: {
        openShipping () {
            this.$emit("global:shippingDialogOpen");
        }
    },
    created () {
    },
};
</script>
<style lang="scss" scoped>
.pricing {
    padding-top: 20px;
}

.pricing-list {
    margin-top: 36px;
}

.pricing-title {
    position: relative;
    padding-right: 120px;

    & > strong {
        font-size: 16px;
        font-family: Roboto-Medium, Roboto;
        font-weight: 500;
        color: #000000;
        line-height: 18px;
        display: flex;
        img {
            width: 18px;
            height: 18px;
            margin-right: 4px;
        }
    }

    & > span {
        display: flex;
        margin-top: 10px;
        font-size: 14px;
        font-family: Roboto-Regular, Roboto;
        font-weight: 400;
        color: #555;
        line-height: 18px;
        margin-left: 24px;
    }

    & > a {
        position: absolute;
        right: 0;
        bottom: 0;
        font-size: 14px;
        color: #000000;
        height: 18px;
        cursor: pointer;
        display: flex;
        align-items: center;

        em {
            text-decoration: underline;
        }
        img {
            width: 16px;
            height: 16px;
            margin-right: 8px;
        }

        &:hover {
            color: #ea4c89;
        }
    }
}

.pricing-switch {
    margin-top: 36px;
    padding: 12px 0;
    display: flex;
    justify-content: right;
    p {
        display: inline-block;
        position: relative;
        height: 18px;
        font-size: 16px;

        color: #000000;
        line-height: 18px;
        padding-left: 30px;
        margin-left: 50px;
        cursor: pointer;
        user-select: none;

        &::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 18px;
            height: 18px;
            border-radius: 9px;
            border: 2px solid #919191;
            box-sizing: border-box;
        }

        &::after {
            display: none;
            content: '';
            position: absolute;
            left: 6px;
            top: 50%;
            transform: translateY(-50%);
            width: 6px;
            height: 6px;
            background: #ea4c89;
            border-radius: 9px;
        }

        &.active {
            &::before {
                border-color: #ea4c89;
            }
            &::after {
                display: block;
            }
        }
    }
}
</style>
